<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta
			http-equiv="origin-trial"
			content="Atzk/dTch1Tt8qYq/UwLn6aWawymlc3xOKy3xiuwsaj1HBK6eCTBb+EGOnv7LK+oSQ8Fr1l/qykGHhK64mAn+w4AAABjeyJvcmlnaW4iOiJodHRwczovL2hwdWdpcy5naXRodWIuaW86NDQzIiwiZmVhdHVyZSI6IldlYkdQVSIsImV4cGlyeSI6MTY5MTcxMTk5OSwiaXNTdWJkb21haW4iOnRydWV9"
		/>
		<title>box</title>
		<!-- <link rel="stylesheet" href="./index.scss" /> -->
		<style>
			* {
				box-sizing: border-box;
			}

			html {
				background: #692a84;
				background: linear-gradient(316deg, #0e0f2a, #060913);
				height: 100%;
				width: 100%;
			}

			body {
				font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
				overflow: hidden;
				height: 100%;
				width: 100%;
				margin: 0;
				padding: 0;
			}

			#app {
				height: 100%;
				width: 100%;
			}
		</style>
		<!-- <script type="module" src="../dist/index.js"></script> -->
	</head>

	<body>
		<div id="app"></div>
		<script type="module">
			import {
				PerspectiveCamera,
				Scene,
				Vector3,
				OrbitControl,
				Sprite,
				Texture,
				Sampler
			} from "../../dist/index.js";
			const init = async () => {
				const scene = new Scene({
					container: "app"
				});
				const camera = new PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.01, 1000);
				camera.position.set(30, 30, 30);
				camera.lookAt(0, 0, 0);
				scene.setCamera(camera);
				const control = new OrbitControl(camera, document.getElementById("app"));
				control.zoomSpeed = 2.0;
				control.maxPolarAngle = Math.PI / 2;

				const response = await fetch(new URL("../textures/Di-3d.png", import.meta.url).toString());
				const imageBitmap = await createImageBitmap(await response.blob());
				const texture = new Texture({
					textureDescriptor: {
						size: {
							width: imageBitmap.width,
							height: imageBitmap.height,
							depth: 1
						},
						format: "rgba8unorm",
						usage:
							GPUTextureUsage.TEXTURE_BINDING |
							GPUTextureUsage.COPY_DST |
							GPUTextureUsage.RENDER_ATTACHMENT
					},
					data: {
						source: imageBitmap,
						width: imageBitmap.width,
						height: imageBitmap.height
					}
				});
				const sampler = new Sampler({
					magFilter: "linear",
					minFilter: "linear"
				});
				const sprite = new Sprite();
				sprite.setTexture(texture);
				sprite.setSampler(sampler);
				sprite.position.set(1, 1, 3);
				sprite.scale.set(10, 10, 1);
				scene.add(sprite);
				function animate() {
					requestAnimationFrame(animate);
					control.update();
					scene.render();
				}
				animate();
			};
			init();
		</script>
	</body>
</html>
